package com.tangula.web.kashine.repository;

import java.util.List;

import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

import com.tangula.web.kashine.entity.ClassEntity;

@Repository
public interface ClassEntityRepository extends JpaRepository<ClassEntity, String>{

	

	Page<ClassEntity> findByOwnerTeacher(String teacherId, Pageable pagination);

	int findCountByOwnerTeacher(String teacherId);

	List<ClassEntity> findByOwnerTeacher(String teacherId);

	List<String> findClassIdByOwnerTeacher(String teacherId);

	String findOwnerTeacherById(String classId);

	boolean existsByIdAndOwnerTeacher(String classId, String teacherId);
	@Query(nativeQuery=true,value="SELECT c.* FROM t_class c, t_account a,t_classstudentref cs WHERE a.id=cs.student_id AND c.id = cs.class_id AND a.email = :studentEmail LIMIT :size")
	List<ClassEntity> showClass(@Param("studentEmail")String condition, @Param("size")int size);
	


}
